/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - resource
// Copyright( c) 2013.  All Rights Reserved
//
// File:		AEAtomic.h
// Author:		Gianluca Belardelli
// Date:		29/09/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AEATOMIC_H_
#define _AEATOMIC_H_

/// \brief
///   Class containing platform-agnostic atomic functionality as a set of static functions
class AEAtomic
{
public:
	/// \brief
	///   Atomically increments the passed value and returns the new value
	AE_FORCEINLINE static AEINT32 Increment( AEINT32 &nValue );

	/// \brief
	///   Atomically decrements the passed value and returns the new value
	AE_FORCEINLINE static AEINT32 Decrement( AEINT32 &nValue );

	AE_FORCEINLINE static AEINT32 CompareAndSwap( AEINT32 &nVar, AEINT32 &nNewVal, AEINT32 &nOldVal );
};

#if defined(AE_PLATFORM_WIN32)
	#include "AEAtomic_win32.inl"
#elif defined(AE_PLATFORM_IOS)
	#include "AEAtomic_ios.inl"
#elif defined(AE_PLATFORM_ANDROID)
	#include "AEAtomic_android.inl"
#elif defined(AE_PLATFORM_MAC386)
    #include "AEAtomic_macosx.inl"
#elif defined(AE_PLATFORM_LINUX)
    #include "AEAtomic_linux.inl"
#else
	#error "Nessuna piattaforma definita."
#endif
#endif // _AEATOMIC_H_
